package com.atguigu.springcloud.payment.controller;

import com.atguigu.springcloud.payment.service.PaymentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lenovo
 * @version 1.0
 * @date 2020/11/11 11:07
 */
@Slf4j
@RestController
@RequestMapping("payment")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class PaymentController {

    final private PaymentService paymentService;

    @Value("${server.port}")
    private Integer port;

    @GetMapping("hystrix/ok/{id}")
    public String getInfoOk(@PathVariable("id") Long id) {
        return "访问端口【"+port+"】  "+paymentService.getInfoOk(id);
    }


    @GetMapping("hystrix/timeout/{id}")
    public String getInfoTimeout(@PathVariable("id") Long id) {
        return "访问端口【"+port+"】  "+paymentService.getInfoTimeout(id);
    }

    @GetMapping("hystrix/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Long id) {
        return "访问端口【"+port+"】  "+paymentService.paymentCircuitBreaker(id);
    }

}
